package exdends_constructor;
// 在任意的构造器中 ，是可以通过this（）去调用该类的其他构造器
public class Text3 {
    public static void main(String[] args) {
        //需求：如果学生没有填写学校，那么学校默认是黑马程序员
        Student s = new Student("张三",23,"家里蹲大学");
        Student s2 = new Student("李四",18);
        System.out.println(s2.getName());
        System.out.println(s2.getAge());
        System.out.println(s2.getSchoolName());
    }
}

class Student{
    private String name;
    private int age;
    private String schoolName;

    public Student() {
    }

    public Student(String name,int age){
//        this.name = name;
//        this.age = age;
//        this.schoolName = "黑马程序员";

        //上面的代码有点多，我们可以通过自己的构造器调用下面的有参构造器
        this(name,age,"黑马程序员");
        //super();  不能同时调用；两次super，而且super（）是放在第一行的，this放第一行是为了调用时进入兄弟构造器的时候先去调用他的super
    }
    public Student(String name, int age, String schoolName) {
        this.name = name;
        this.age = age;
        this.schoolName = schoolName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSchoolName() {
        return schoolName;
    }

    public void setSchoolName(String schoolName) {
        this.schoolName = schoolName;
    }
}